package org.apache.http.a;

import java.io.Serializable;
import org.apache.http.annotation.NotThreadSafe;

@NotThreadSafe
public final class c implements Serializable {
    private byte[] a;
    private int b;

    public c(int i) {
        a.a(i, "Buffer capacity");
        this.a = new byte[i];
    }

    private void a(int i) {
        Object obj = new byte[Math.max(this.a.length << 1, i)];
        System.arraycopy(this.a, 0, obj, 0, this.b);
        this.a = obj;
    }

    public int a() {
        return this.b;
    }

    public void a(byte[] bArr, int i, int i2) {
        if (bArr != null) {
            if (i < 0 || i > bArr.length || i2 < 0 || i + i2 < 0 || i + i2 > bArr.length) {
                throw new IndexOutOfBoundsException("off: " + i + " len: " + i2 + " b.length: " + bArr.length);
            } else if (i2 != 0) {
                int i3 = this.b + i2;
                if (i3 > this.a.length) {
                    a(i3);
                }
                System.arraycopy(bArr, i, this.a, this.b, i2);
                this.b = i3;
            }
        }
    }

    public byte[] b() {
        return this.a;
    }
}
